<template>
	<view class="bullMost" :catchtouchmove="true">
		<view class="bullMost-box">
			<view class=""> 答题结果 </view>
			<view class="allOk" v-if="isOk">
				<view class="">
					<image src="https://images.linglinggong.net/static/allOk.png" mode=""></image>
					<view class="">
						<text>恭喜您，合格。</text>
						<text>已为您切换身份！</text>
					</view>
				</view>
				<view class="" @click="toIndex"> 前往首页 </view>
			</view>
			<view class="allWrong" v-else>
				<view class="">
					<image src="https://images.linglinggong.net/static/allWrong.png" mode=""></image>
					<view class=""> 真遗憾，不合格！ </view>
				</view>
				<view class="">
					<view class="" @click="close"> 取消切换 </view>
					<view class="" @click="onrest"> 重新答题 </view>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		name: 'bullMosk',
		props: {
			isOk: {
				type: Boolean,
				default: false
			},
			typeUser: {
				type: [Number, String],
				default: 0
			}
		},
		data() {
			return {
				flag: true
			}
		},
		methods: {
			async getConfigBanner(e) {
				let tempRegion
				// #ifdef H5
				tempRegion = '330782'
				// #endif
				// #ifdef APP-PLUS
				tempRegion = uni.getStorageSync('region1').slice(0, 6)
				// #endif
				let res = await this.$fetch(this.$api.bannerByToken, {
					region: e ? e : tempRegion
				}, 'GET')
				if (res.code) return uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				let newList = []
				for (let i = 0; i < res.data.length; i++) {
					let resdate = res.data[i]
					resdate.img = `https://images.linglinggong.net/${resdate.img}`
					newList.push(resdate)
				}
				uni.setStorageSync('configBanner', newList)
				return
			},
			close() {
				this.$emit('onclose')
			},
			onrest() {
				this.$emit('getRest')
			},
			async toIndex() {
				if (!this.flag) return
				this.flag = false;
				let num = uni.getStorageSync("userType");
				uni.showLoading({
					title: "切换中..."
				});
				let that = this;
				let time = setInterval(async () => {
					let res = await that.$fetch(that.$api.get_current_user, {}, "GET");
					if (res.code) return;
					if (res.data.userType != num) {
						uni.hideLoading();
						clearInterval(time);
						uni.hideLoading();
						uni.setStorageSync('userType', res.data.userType)
						uni.reLaunch({
							url: '/pages/index/index',
						});
					}
				}, 1500)
			}
		},
	}
</script>
<style lang="scss" scoped>
	.bullMost {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.3);
		display: grid;
		place-items: center;
		overflow: hidden;

		&-box {
			width: 630rpx;
			height: 608rpx;
			background: #FFF;
			border-radius: 24rpx;
			display: flex;
			flex-direction: column;
			align-items: center;

			&>view:nth-child(1) {
				font-size: 40rpx;
				font-weight: 800;
				color: #262626;
				margin: 40rpx auto;
			}

			.allOk {
				&>view:nth-child(1) {
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 152rpx;
						height: 156rpx;
						margin-bottom: 40rpx;
					}

					&>view {
						display: flex;
						flex-direction: column;
						margin-bottom: 58rpx;
						height: 88rpx;

						text {
							font-size: 32rpx;
							font-weight: bold;
							color: #515151;
							text-align: center;
						}

						&>text:first-child {
							margin-bottom: 10rpx;
						}
					}
				}

				&>view:nth-child(2) {
					width: 510rpx;
					height: 88rpx;
					background: #FCC92D;
					box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(252, 201, 45, 0.3);
					border-radius: 12rpx;
					text-align: center;
					line-height: 88rpx;
					font-size: 28rpx;
					font-weight: bold;
				}
			}

			.allWrong {
				width: 100%;

				&>view:nth-child(1) {
					display: flex;
					flex-direction: column;
					align-items: center;

					image {
						width: 152rpx;
						height: 156rpx;
						margin-bottom: 40rpx;
					}

					&>view {
						font-size: 32rpx;
						font-weight: bold;
						color: #515151;
						text-align: center;
					}
				}

				&>view:nth-child(2) {
					margin-top: 96rpx;
					display: flex;
					justify-content: space-between;

					&>view:first-child {
						width: 254rpx;
						height: 96rpx;
						background: #FFFFFF;
						border-radius: 12rpx;
						opacity: 1;
						border: 2rpx solid #FF851D;
						font-size: 28rpx;
						font-weight: bold;
						color: #FF851D;
						line-height: 96rpx;
						text-align: center;
						margin-left: 30rpx;
					}

					&>view:last-child {
						width: 254rpx;
						height: 100rpx;
						background: #FCC92D;
						box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(252, 201, 45, 0.3);
						border-radius: 12rpx;
						font-size: 28rpx;
						color: #262626;
						font-weight: bold;
						line-height: 100rpx;
						text-align: center;
						margin-right: 30rpx;
					}
				}
			}
		}
	}
</style>